from model.uml_element import UmlElement
from model.uml_package_import import UmlPackageImport
from model.uml_stereotype import UmlStereotype
from model.uml_extension import UmlExtension
from model.uml_xmi_info import UmlXmiInfo


class UmlProfile(UmlElement):
    def __init__(self) -> None:
        super().__init__(UmlXmiInfo.type_profile)
        self.name: str = ""
        self.metamodelReference: str = ""
        self.uri: str = ""
        self.packageImports: list[UmlPackageImport] = []
        self.packagedElements: dict[str, UmlStereotype | UmlExtension] = {}

    def to_json(self) -> dict[str, object]:
        json: dict = super().to_json()
        json["name"] = self.name
        json["metamodelReference"] = self.metamodelReference
        json["uri"] = self.uri

        item = []
        for value in self.packageImports:
            item.append(value.to_json())
        json["packageImports"] = item

        item = {}
        for key, value in self.packagedElements.items():
            item[key] = value.to_json()
        json["packagedElements"] = item

        return json
